//
//  YYTopMenuView.h
//  NNHealthMall
//
//  Created by 蓓蕾 on 2021/8/20.
//  Copyright © 2021 YY. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


@interface YYIndexPath : NSObject

@property (nonatomic, assign) NSInteger row; //行
@property (nonatomic, assign) NSInteger column; //列
@property (nonatomic, assign) NSInteger item; //item

- (instancetype)initWithColumn:(NSInteger)column row:(NSInteger)row;

+ (instancetype)indexPathWithColumn:(NSInteger)column row:(NSInteger)row;
+ (instancetype)indexPathWithColumn:(NSInteger)column row:(NSInteger)row item:(NSInteger)item;

@end

#pragma  mark - datasource
@class YYTopMenuView;
@protocol YYMenuDataSource <NSObject>

@required
//每个column有多少行
- (NSInteger)menu:(YYTopMenuView *)menu numberOfRowsInColumn:(NSInteger)column;
//每个column中每行的title
- (NSString *)menu:(YYTopMenuView *)menu titleForRowAtIndexPath:(YYIndexPath *)indexPath;

@optional
//有多少个column，默认为1列
- (NSInteger)numberOfColumnsInMenu:(YYTopMenuView *)menu;
//第column列，每行的image
- (NSString *)menu:(YYTopMenuView *)menu imageNameForRowAtIndexPath:(YYIndexPath *)indexPath;
//detail text
- (NSString *)menu:(YYTopMenuView *)menu detailTextForRowAtIndexPath:(YYIndexPath *)indexPath;
//某列的某行item的数量，如果有，则说明有二级菜单，反之亦然
- (NSInteger)menu:(YYTopMenuView *)menu numberOfItemsInRow:(NSInteger)row inColumn:(NSInteger)column;
//如果有二级菜单，则实现下列协议
//二级菜单的标题
- (NSString *)menu:(YYTopMenuView *)menu titleForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
//二级菜单的image
- (NSString *)menu:(YYTopMenuView *)menu imageForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
//二级菜单的detail text
- (NSString *)menu:(YYTopMenuView *)menu detailTextForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
@end

#pragma mark - delegate
@protocol YYMenuDelegate <NSObject>

@optional
//点击
- (void)menu:(YYTopMenuView *)menu didSelectRowAtIndexPath:(YYIndexPath *)indexPath;

@end




@interface YYTopMenuView : UIView

@property (nonatomic, weak) id<YYMenuDelegate> delegate;
@property (nonatomic, weak) id<YYMenuDataSource> dataSource;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, strong) UIColor *selectedTextColor;
@property (nonatomic, strong) UIColor *detailTextColor;
@property (nonatomic, strong) UIColor *indicatorColor;
@property (nonatomic, strong) UIFont *detailTextFont;
@property (nonatomic, strong) UIColor *separatorColor;
@property (nonatomic, assign) NSInteger fontSize;

@property (nonatomic, strong) UIView *fatherView;

//当前选中的列
@property (nonatomic, strong) NSMutableArray *currentSelectedRows;
//当有二级列表的时候，是否调用点击代理方法
@property (nonatomic, assign) BOOL isClickHaveItemValid;
/** 每个Item的默认标题 */
@property (nonatomic, strong) NSArray *defaultColumnItemArr;

/** 筛选菜单 - 左边的菜单数组 */
@property (nonatomic, strong) NSArray *leftTitleArr;
/** 筛选菜单 - 右边的内容数组 */
@property (nonatomic, strong) NSArray *rightContentArr;
/** 筛选菜单 - item距离上方的距离 默认：10 */
@property (nonatomic, assign) CGFloat topMargin;
/** 筛选菜单 - item距离下方的距离 默认：10 */
@property (nonatomic, assign) CGFloat bottomMargin;
/** 筛选菜单 - item距离两侧的距离 默认：10 */
@property (nonatomic, assign) CGFloat leftMargin;
/** 筛选菜单 - item与item之间的水平间隔 默认：10 */
@property (nonatomic, assign) CGFloat itemHorizontalMargin;
/** 筛选菜单 - item与item之间的间隔垂直 默认：10 */
@property (nonatomic, assign) CGFloat itemVerticalMargin;
/** 筛选菜单 - item的宽度，autoSize为NO时有效，默认：70 */
@property (nonatomic, assign) CGFloat itemWidth;
/** 筛选菜单 - item的高度，默认：25 */
@property (nonatomic, assign) CGFloat itemHeight;
/** 筛选菜单 - 每行排版多少个 默认：4 */
@property (nonatomic, assign) NSInteger itemLineCount;

@property (nonatomic, assign) BOOL showAnimation;

@property (nonatomic, assign) BOOL allowShowSelectView;

/** 筛选菜单 - 是否自适应Item大小，默认NO */
@property (nonatomic, assign) BOOL autoSize;

@property (nonatomic, assign) BOOL shaiXuanViewHidden;

//获取title
- (NSString *)titleForRowAtIndexPath:(YYIndexPath *)indexPath;
//初始化方法
- (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height;
-(instancetype)initWithOrigin:(CGPoint)origin andDefaultColumnArr:(NSArray *)defaultColumnItemArr andNormalImageArr:(NSArray *)normalImageArr andSelectImageArr:(NSArray *)selectImageArr andHeight:(CGFloat)height;
//菜单切换，选中的indexPath
- (void)selectIndexPath:(YYIndexPath *)indexPath;
//默认选中
- (void)selectDeafultIndexPath;
//数据重载
- (void)reloadData;

-(void)initSelectView;

-(void)selectItemWithIndexPath:(YYIndexPath *)indexPath;

-(void)showColumnView:(NSInteger)column;
-(void)ShaiXuanMethod;

-(void)selectShaiXuanItemWithLeftRow:(NSInteger)row withIndex:(NSInteger)index;
/** 选择筛选菜单中的某个item是的回调 （如：筛选 → 体检类型 → 健康体检） */
@property (nonatomic, copy) void (^SelectShaiXuanItemBlock)(NSInteger leftRow, NSInteger index);
/** 点击某个column下某个选项的回调  （如：医院等级 → 三甲医院） */
@property (nonatomic, copy) void (^SelectIndexPathBlock)(YYIndexPath *indexPath);
/** 展开某个Column的回调 */
@property (nonatomic, copy) void (^GetCurrenSelectColumnBlock)(NSInteger column, BOOL isShow);
/** 展示筛选（菜单 / View）时的回调 */
@property (nonatomic, copy) void (^SelectShaiXuanBlock)(void);
/** 隐藏筛选（菜单 / View）时的回调 */
@property (nonatomic, copy) void (^HiddenShaiXuanViewBlock)(void);
/** 点击筛选按钮的回调 */
@property (nonatomic, copy) void (^ShaiXuanBlock)(void);

-(YYIndexPath *)getCurrentIndexPath;

-(void)setOrigin:(CGPoint)origin;

-(void)hiddenSelectView;

@end

NS_ASSUME_NONNULL_END



















////
////  YYTopMenuView.h
////  NNHealthMall
////
////  Created by 蓓蕾 on 2021/8/20.
////  Copyright © 2021 YY. All rights reserved.
////
//
//#import <UIKit/UIKit.h>
//
//NS_ASSUME_NONNULL_BEGIN
//
//
//@interface YYIndexPath : NSObject
//
//@property (nonatomic, assign) NSInteger row; //行
//@property (nonatomic, assign) NSInteger column; //列
//@property (nonatomic, assign) NSInteger item; //item
//
//- (instancetype)initWithColumn:(NSInteger)column row:(NSInteger)row;
//
//+ (instancetype)indexPathWithColumn:(NSInteger)column row:(NSInteger)row;
//+ (instancetype)indexPathWithColumn:(NSInteger)column row:(NSInteger)row item:(NSInteger)item;
//
//@end
//
//#pragma  mark - datasource
//@class YYTopMenuView;
//@protocol YYMenuDataSource <NSObject>
//
//@required
////每个column有多少行
//- (NSInteger)menu:(YYTopMenuView *)menu numberOfRowsInColumn:(NSInteger)column;
////每个column中每行的title
//- (NSString *)menu:(YYTopMenuView *)menu titleForRowAtIndexPath:(YYIndexPath *)indexPath;
//
//@optional
////有多少个column，默认为1列
//- (NSInteger)numberOfColumnsInMenu:(YYTopMenuView *)menu;
////第column列，每行的image
//- (NSString *)menu:(YYTopMenuView *)menu imageNameForRowAtIndexPath:(YYIndexPath *)indexPath;
////detail text
//- (NSString *)menu:(YYTopMenuView *)menu detailTextForRowAtIndexPath:(YYIndexPath *)indexPath;
////某列的某行item的数量，如果有，则说明有二级菜单，反之亦然
//- (NSInteger)menu:(YYTopMenuView *)menu numberOfItemsInRow:(NSInteger)row inColumn:(NSInteger)column;
////如果有二级菜单，则实现下列协议
////二级菜单的标题
//- (NSString *)menu:(YYTopMenuView *)menu titleForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
////二级菜单的image
//- (NSString *)menu:(YYTopMenuView *)menu imageForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
////二级菜单的detail text
//- (NSString *)menu:(YYTopMenuView *)menu detailTextForItemsInRowAtIndexPath:(YYIndexPath *)indexPath;
//@end
//
//#pragma mark - delegate
//@protocol YYMenuDelegate <NSObject>
//
//@optional
////点击
//- (void)menu:(YYTopMenuView *)menu didSelectRowAtIndexPath:(YYIndexPath *)indexPath;
//
//@end
//
//
//
//
//@interface YYTopMenuView : UIView
//
//@property (nonatomic, weak) id<YYMenuDelegate> delegate;
//@property (nonatomic, weak) id<YYMenuDataSource> dataSource;
//@property (nonatomic, strong) UIColor *textColor;
//@property (nonatomic, strong) UIColor *selectedTextColor;
//@property (nonatomic, strong) UIColor *detailTextColor;
//@property (nonatomic, strong) UIColor *indicatorColor;
//@property (nonatomic, strong) UIFont *detailTextFont;
//@property (nonatomic, strong) UIColor *separatorColor;
//@property (nonatomic, assign) NSInteger fontSize;
////当前选中的列
//@property (nonatomic, strong) NSMutableArray *currentSelectedRows;
////当有二级列表的时候，是否调用点击代理方法
//@property (nonatomic, assign) BOOL isClickHaveItemValid;
///** 每个Item的默认标题 */
//@property (nonatomic, strong) NSArray *columnItemArr;
//
////获取title
//- (NSString *)titleForRowAtIndexPath:(YYIndexPath *)indexPath;
////初始化方法
//- (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height;
////菜单切换，选中的indexPath
//- (void)selectIndexPath:(YYIndexPath *)indexPath;
////默认选中
//- (void)selectDeafultIndexPath;
////数据重载
//- (void)reloadData;
//
//@end
//
//NS_ASSUME_NONNULL_END
